import Http from './../http/chatApiHttp'
export  default class UserServuce {
  getUserDetail(params){
    return new Promise((resove,reject)=>{
      Http.request({
        data:params,
        method:'POST',
        url:'/im/getUserDetail'
      }).then((res)=>{
        try {
          resove(res.returnObj)
        }
        catch(err) {
          console.log(err)
        }

      })
    })
  }
  //获取用户列表
   getUserList(params){
    return new Promise((resolve)=>{
      Http.request({
        data:params,
        method:'POST',
        url:'/im/getContacts'
      }).then((res)=>{
        resolve(res.returnObj);
      })
    })
   }

   setUserTalking(_this){
     _this.chatList.forEach((item,index)=>{
       if(index===0){
         _this.$set(item,'isTalking',true);
         _this.$store.dispatch('changeChatObject',item);
       }else{
         _this.$set(item,'isTalking',false)
       }
     })
   }
   setUserDataInit(userData,type){
     userData.forEach((item)=>{
       item[type] = false
     });
   }
   setUserStatus(params){
      return new Promise((resove,reject)=>{
        Http.request({
          data:params,
          method:'POST',
          url:'/pub/getUserStatus'
        }).then((res)=>{
          try {
            resove(res.status)
          }
          catch(err) {
            console.log(err)
          }
        })
      })
   }
}